@echo off
echo 开始修复Teacher相关类文件问题...

REM 检查并创建目标目录
if not exist ".\scms-admin\src\main\java\com\scms\secondclass\domain" (
    mkdir ".\scms-admin\src\main\java\com\scms\secondclass\domain"
    echo 创建目录: .\scms-admin\src\main\java\com\scms\secondclass\domain
)

if not exist ".\scms-admin\src\main\java\com\scms\secondclass\mapper" (
    mkdir ".\scms-admin\src\main\java\com\scms\secondclass\mapper"
    echo 创建目录: .\scms-admin\src\main\java\com\scms\secondclass\mapper
)

if not exist ".\scms-admin\src\main\resources\mapper\secondclass" (
    mkdir ".\scms-admin\src\main\resources\mapper\secondclass"
    echo 创建目录: .\scms-admin\src\main\resources\mapper\secondclass
)

REM 复制Teacher.java
if exist ".\scms-secondclass\src\main\java\com\scms\secondclass\domain\Teacher.java" (
    copy ".\scms-secondclass\src\main\java\com\scms\secondclass\domain\Teacher.java" ".\scms-admin\src\main\java\com\scms\secondclass\domain\Teacher.java" /Y
    echo 复制文件: Teacher.java
) else (
    echo 错误: 找不到源文件 Teacher.java
    exit /b 1
)

REM 复制TeacherRole.java
if exist ".\scms-secondclass\src\main\java\com\scms\secondclass\domain\TeacherRole.java" (
    copy ".\scms-secondclass\src\main\java\com\scms\secondclass\domain\TeacherRole.java" ".\scms-admin\src\main\java\com\scms\secondclass\domain\TeacherRole.java" /Y
    echo 复制文件: TeacherRole.java
) else (
    echo 错误: 找不到源文件 TeacherRole.java
    exit /b 1
)

REM 复制TeacherMapper.java
if exist ".\scms-secondclass\src\main\java\com\scms\secondclass\mapper\TeacherMapper.java" (
    copy ".\scms-secondclass\src\main\java\com\scms\secondclass\mapper\TeacherMapper.java" ".\scms-admin\src\main\java\com\scms\secondclass\mapper\TeacherMapper.java" /Y
    echo 复制文件: TeacherMapper.java
) else (
    echo 错误: 找不到源文件 TeacherMapper.java
    exit /b 1
)

REM 复制TeacherRoleMapper.java
if exist ".\scms-secondclass\src\main\java\com\scms\secondclass\mapper\TeacherRoleMapper.java" (
    copy ".\scms-secondclass\src\main\java\com\scms\secondclass\mapper\TeacherRoleMapper.java" ".\scms-admin\src\main\java\com\scms\secondclass\mapper\TeacherRoleMapper.java" /Y
    echo 复制文件: TeacherRoleMapper.java
) else (
    echo 错误: 找不到源文件 TeacherRoleMapper.java
    exit /b 1
)

REM 复制TeacherMapper.xml
if exist ".\scms-secondclass\src\main\resources\mapper\secondclass\TeacherMapper.xml" (
    copy ".\scms-secondclass\src\main\resources\mapper\secondclass\TeacherMapper.xml" ".\scms-admin\src\main\resources\mapper\secondclass\TeacherMapper.xml" /Y
    echo 复制文件: TeacherMapper.xml
) else (
    echo 错误: 找不到源文件 TeacherMapper.xml
    exit /b 1
)

REM 复制TeacherRoleMapper.xml
if exist ".\scms-secondclass\src\main\resources\mapper\secondclass\TeacherRoleMapper.xml" (
    copy ".\scms-secondclass\src\main\resources\mapper\secondclass\TeacherRoleMapper.xml" ".\scms-admin\src\main\resources\mapper\secondclass\TeacherRoleMapper.xml" /Y
    echo 复制文件: TeacherRoleMapper.xml
) else (
    echo 错误: 找不到源文件 TeacherRoleMapper.xml
    exit /b 1
)

echo 文件复制完成，开始清理和编译项目...

REM 清理和编译项目
cd scms-admin
call mvn clean compile

if %ERRORLEVEL% NEQ 0 (
    echo 编译失败，请检查错误信息。
    exit /b 1
)

echo 编译成功！
echo 修复完成。

exit /b 0 